package cn.wolfcode.trip.api.controller;

import cn.wolfcode.trip.base.domain.Store;
import cn.wolfcode.trip.base.query.StoreQuery;
import cn.wolfcode.trip.base.service.IStoreService;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("stores")
public class StoreController {
    @Autowired
    private IStoreService storeService;
    @GetMapping
    public PageInfo list(StoreQuery query){
        //查询所有上架的商品
        query.setShelves(true);
        return storeService.query(query);
    }

    @GetMapping("{id}")
    public Store get(@PathVariable Long id){
        return storeService.selectById(id);
    }
}
